const Controllers = require('../controllers/index');
const adminRoutes = require('./admin');
const validate = require('../middlewares/validate');
const commodityRoutes = require('./commodity');
const newsRoutes = require('./news');
const callingCardRoutes = require('./callingCard');

const routes = [
  {
    path: '/test/:id?',
    method: 'post',
    validate: validate({
      'age': 'required|in:10,18',
      'uid': 'required|number|min:2|max:5',
      'filter': 'in:1,2,3',
      'category': 'number'
    },
    {
      'age.in': 'age必须在10或18',
      'age.required': 'age为必填项',
      'uid.required': 'uid 是必须的',
      'uid.numeric': 'uid 必须是数字',
      'filter.in': 'filter 必须在(1,2,3)范围内',
      'category.number': 'category 必须为数字'
    }),
    controller: Controllers.test
  },
  {
    path: '/api/login',
    method: 'get',
    validate: validate({
      'username': 'required|min:3|max:50',
      'password': 'required|min:3|max:50',
    },
    {
      'username.required': 'username必填',
      'username.min': 'username不得小于3位',
      'username.max': 'username不得大于50位',
      'password.required': 'password为必填项',
      'password.min': 'password不得小于3位',
      'password.max': 'password不得大于50位',
    }),
    controller: Controllers.login
  },
  {
    path: '/api/user/info',
    method: 'get',
    validate: validate(),
    controller: Controllers.getUserInfo
  },
  {
    path: '/users',
    method: 'get',
    validate: validate({
      // 'uid': 'required|number',
    },
    {
      'uid.required': 'uid必填',
      'uid.int': 'uid必须为number类型',
    }),
    controller: Controllers.users
  },
  {
    path: '/uploadFile',
    method: 'post',
    validate: validate(),
    controller: Controllers.uploadFile
  },
  // {
  //   path: '/sendCos',
  //   method: 'post',
  //   validate: validate(),
  //   controller: Controllers.sendCos
  // },
  // ...adminRoutes,
  // ...commodityRoutes,
  // ...newsRoutes,
  // ...callingCardRoutes
]

module.exports = routes;